#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<unordered_map>
#include<queue>
#include<stack>

using namespace std;

struct TreeNode {
     int val;
     TreeNode *left;
     TreeNode *right;
     TreeNode() : val(0), left(nullptr), right(nullptr) {}
     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 };

class Solution {
public:
    int widthOfBinaryTree(TreeNode* root) {
        vector<pair<TreeNode*, unsigned int>> qt;
        unsigned int ret = 0;
        qt.push_back({ root,1 });
        while (qt.size())
        {
            auto& [x1, y1] = qt[0];
            auto& [x2, y2] = qt.back();
            ret = max(ret, y2 - y1 + 1);
            vector<pair<TreeNode*, unsigned int>> tmp;
            for (auto& [x, y] : qt)
            {
                if (x->left) tmp.push_back({ x->left,y * 2 });
                if (x->right) tmp.push_back({ x->right,y * 2 + 1 });
            }
            qt = tmp;
        }
        return ret;
    }
};
int main() {
    return 0;
}